import 'package:flutter/material.dart';
import 'package:honeypotflutter/publicBussine/bussine_colors.dart';
import 'package:honeypotflutter/publicBussine/bussine_font.dart';

class PreferencesAddItem extends StatelessWidget {
  final String title;
  final bool enable;
  final String? hintText;
  final FocusNode? focusNode;
  final TextEditingController? controller;
  final bool showTrailing;
  final Function()? action;

  const PreferencesAddItem({
    super.key,
    this.enable = false,
    this.hintText,
    this.focusNode,
    this.controller,
    this.title = "手机号",
    this.showTrailing = false,
    this.action,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Row(
          children: [
            Container(
              color: MGColors.themeColor,
              width: 4,
              height: 13,
              margin: EdgeInsets.only(right: 10),
            ),
            Text(
              title,
              style: TextStyle(
                fontSize: MGFont.textFont2,
                color: MGColors.text1Color,
                fontWeight: FontWeight.bold,
              ),
            ),
          ],
        ),
        InkWell(
          child: Container(
            margin: EdgeInsets.only(top: 10),
            padding: EdgeInsets.only(left: 12),
            decoration: BoxDecoration(
              border: Border.all(color: MGColors.splitColor, width: 1),
              borderRadius: BorderRadius.circular(6),
            ),
            child: Row(
              children: [
                Expanded(
                    child: TextField(
                        style: TextStyle(
                          color: MGColors.text1Color,
                          fontSize: MGFont.textFont1,
                        ),
                        focusNode: focusNode,
                        enabled: enable,
                        controller: controller,
                        decoration: InputDecoration(
                          hintText: hintText,
                          hintStyle: TextStyle(color: MGColors.text3Color, fontSize: MGFont.textFont1),
                          enabledBorder: UnderlineInputBorder(borderSide: BorderSide(color: Colors.transparent)),
                          disabledBorder: UnderlineInputBorder(borderSide: BorderSide(color: Colors.transparent)),
                          focusedBorder: UnderlineInputBorder(borderSide: BorderSide(color: Colors.transparent)),
                        ))),
                showTrailing
                    ? Icon(
                        Icons.chevron_right_outlined,
                        color: MGColors.text4Color,
                      )
                    : Container(),
              ],
            ),
          ),
          onTap: () {
            if (this.action != null) {
              this.action!();
            }
          },
        )
      ],
    );
  }
}
